package capricornus.actor.controller
{
	import capricornus.actor.Actor;

	/**
	 * 眩晕控制器 
	 * @author kael
	 * 
	 */	
	public class ActorStunController
	{
		/**
		 * 是否眩晕 
		 */		
		protected var _stunning:Boolean = false;
		/**
		 * 眩晕时间 
		 */		
		protected var _stunDuration:int;
		/**
		 * Actor对象 
		 */		
		protected var _actor:Actor;
		
		public function ActorStunController( actor:Actor )
		{
			_actor = actor;
		}
		
		/**
		 * 销毁 
		 */		
		public function destroy():void
		{
		}
		
		/**
		 * 开始眩晕 
		 * @param duration
		 */		
		public function start( duration:int ):void
		{
			if( _stunDuration < duration )
			{
				_stunDuration = duration;
			}
			_stunning = _stunDuration > 0;
		}
		
		/**
		 * 是否眩晕中 
		 * @return 
		 */		
		public function get stunning():Boolean
		{
			return _stunning;
		}
		
		/**
		 * 刷新 
		 * @param time
		 */		
		public function refresh( time:int ):void
		{
			if( _stunning )
			{
				_stunDuration -= time;
				if( _stunDuration < 1 )
				{
					_stunning = false;
					_actor.wakeUp();
				}
			}
		}
	}
}